<?php

namespace app\components;

use Yii;
use yii\captcha\CaptchaAction;

class Captcha extends CaptchaAction {

    public function __construct($controller, $config = array()) {
        return parent::__construct('captcha', $controller, $config);
    }

    /**
     * @var integer the minimum length for randomly generated word. Defaults to 6.
     */
    public $minLength = 4;

    /**
     * @var integer the maximum length for randomly generated word. Defaults to 7.
     */
    public $maxLength = 4;

    /**
     * @var integer the background color. For example, 0x55FF00.
     * Defaults to 0xFFFFFF, meaning white color.
     */
    public $backColor = 0xEEEEEE;

    /**
     * @var integer the font color. For example, 0x55FF00. Defaults to 0x2040A0 (blue color).
     */
    public $foreColor = 0x0062C6;

    public function run() {

        $val = parent::run();

        if (isset($_GET[CaptchaAction::REFRESH_GET_VAR])) {
            echo json_encode($val);
        } else {
            echo $val;
        }
    }

}
